package com.example.demo.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.io.Serial;
import java.io.Serializable;
import java.util.Date;
import java.util.LinkedHashMap;
import java.util.Map;

/**
 * @description：实体类父类.
 * @author：lw
 * @since：2023/12/26
 **/

@Data
//序列化是将对象的状态信息转换为适合存储或传输的形式的过程。反序列化是将已序列化的数据重新构建为原来的对象结构的过程，这对于数据交换、持久化状态恢复、以及分布式系统的设计都至关重要。
public class BaseEntity implements Serializable {
    @Schema(description = "主键id")
    @TableId(type = IdType.AUTO)
    private Long id;

    @Schema(description = "创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date createTime;

    @Schema(description = "更新时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date updateTime;

    @Schema(description = "删除状态")
    private Integer isDeleted;

    @Schema(description = "开始时间。用作查询筛选条件")
    @TableField(exist = false)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date startTime;

    @Schema(description = "结束时间。用作查询筛选条件")
    @TableField(exist = false)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date endTime;

    public static final String is_deleted_field="is_deleted";

    public static Map<String,String> getExcelCols(){
        Map<String,String> map=new LinkedHashMap<>();
        map.put("id","id");
        map.put("createTime","创建时间");
        map.put("updateTime","更新时间");
        return map;
    }
}
